package demo.security.error;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

public class DemoOauthExceptionSerializer extends StdSerializer<DemoOauth2Exception> {

	private static final long serialVersionUID = 1L;

	public DemoOauthExceptionSerializer() {
		super(DemoOauth2Exception.class);
	}
	
	@Override
	public void serialize(DemoOauth2Exception value, JsonGenerator generator, SerializerProvider provider) throws IOException {
		generator.writeStartObject();
		
		generator.writeStringField("httpErrorCode",String.valueOf(value.getHttpErrorCode()));
		generator.writeStringField("message",value.getMessage());
		generator.writeStringField("oAuth2ErrorCode",value.getOAuth2ErrorCode());
		
		generator.writeEndObject();		
	}

}
